package com.sbeisenov.students.common.service;

import com.sbeisenov.students.common.model.FooterInfo;
import com.sbeisenov.students.common.model.ForecastData;
import com.sbeisenov.students.common.model.HelloWorldModel;

import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;

public class HelloWorldService {
    public HelloWorldModel getHelloWorldData() {
        HelloWorldModel model = new HelloWorldModel();
        init(model);
        return model;
    }

    private void init(HelloWorldModel model) {
        List<String> menuitems = new ArrayList<String>();
        menuitems.add("Home");
        menuitems.add("About Us");
        menuitems.add("Contacts");

        List<ForecastData> forecasts = new ArrayList<ForecastData>();
        ForecastData day1 = new ForecastData(createDate(2013, 10, 29), 2 ,3);
        ForecastData day2 = new ForecastData(createDate(2013, 10, 30), -3 ,0);
        forecasts.add(day1);
        forecasts.add(day2);

        List<String> phones = new ArrayList<String>();
        phones.add("23-23-23");
        phones.add("32-32-32");
        FooterInfo footerInfo = new FooterInfo(new Date(), phones);

        model.setMenuItems(menuitems);
        model.setForecastData(forecasts);
        model.setFooterInfo(footerInfo);
    }

    private Date createDate(int year, int month, int day) {
        return new GregorianCalendar(year, month, day).getTime();
    }
}
